package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 实现简易记事本工具
 * 程序启动后在控制台输入的每一行字符串都能顺序写文件note.txt中.
 * 当单独输入exit时程序退出.
 */
public class Test {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos
                = new FileOutputStream("note.txt");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请开始输入内容.单独输入exit时退出!");
        while(true){
            String line = scanner.nextLine();
            if("exit".equals(line)){
                break;
            }
            byte[] data = line.getBytes(StandardCharsets.UTF_8);
            fos.write(data);
        }
        System.out.println("再见!");
        fos.close();


    }
}



